# -*- coding: utf-8 -*-

from 掘金3_分钟回测.专用的分析包 import *


def 根据落在与均线差值的占比得出结论(当前价位=0, data=None, 周期=90, 默认的购入范围=0.2):
    统计结果 = 显示偏离MA的震荡周期内的最极值的差值是多少(data=data, 周期=90, 获取数据=1)
    # 找出落在区间80%的范围
    max = 40
    min = -40

    data_max = [i for i in 统计结果 if i > 0]  # .sort()
    data_min = [i for i in 统计结果 if i < 0]  # .sort()

    for i in range(len(data_max)):
        for j in range(len(data_max)):
            if data_max[i] < data_max[j]:
                data_max[i], data_max[j] = data_max[j], data_max[i]
    for i in range(len(data_min)):
        for j in range(len(data_min)):
            if data_min[i] < data_min[j]:
                data_min[i], data_min[j] = data_min[j], data_min[i]
    # 可以接收的范围是
    # data_min[int(len(data_min)*默认的购入范围)]
    print(data_min)

    print(data_min[int(len(data_min)*默认的购入范围)])
    # print('0.1')

    # data_min
    # data_max

    # for i in range(len(统计结果)):
    #     pass

    print("buy")

    return 'buy'
